package com.ibm.spatiotemp.processor.splitter;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;

import org.apache.hadoop.io.Text;
import org.apache.log4j.Logger;

import com.ibm.spatiotemp.datamodel.datatype.TemporalLineString;
import com.ibm.spatiotemp.datamodel.datatype.timeseries.GPSTimeseries;

public class MockLineStringSplitter extends LinestringSplitter{
	public static Logger logger = Logger
			.getLogger(MockLineStringSplitter.class);
	
	@Override
	public Collection<TemporalLineString> splitTimeseriesDatatoLineString(
			GPSTimeseries timeseries) {
		Collection<TemporalLineString> linestrset = new LinkedList<TemporalLineString>();
		logger.warn("only see in test, output test linestring set");
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new FileReader(new File(
					"test_linestr/data_00001")));
			String curline = null;
			do {
				curline = reader.readLine();
				if (curline != null && curline.trim() != "") {
					TemporalLineString curobj = new TemporalLineString();
					curobj.fromText(new Text(curline));
					linestrset.add(curobj);
				} else {
					break;
				}
			} while (curline != null);
			reader.close();

		} catch (FileNotFoundException e) {
			logger.error("file not found");
		} catch (IOException e) {
			logger.error("io error");
		}
		return linestrset;
	}

}
